package com.rj.bd.person.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.rj.bd.person.entity.Person;
import com.rj.bd.reservation.entity.Reservation;
import com.rj.bd.sex.entity.Sex;

public interface PersonMapper extends BaseMapper<Person> {

	@Select("select * from person ${ew.customSqlSegment}")
	@Results(value={
			@Result(javaType=Sex.class,column="sexId",property="sex",
					one=@One(select="com.rj.bd.sex.dao.SexMapper.selectById")),
			
			@Result(javaType=String.class,column="sexId",property="sexId"),
	})
	IPage<Person> selectPage(IPage<Person> page, @Param("ew") Wrapper<Person> queryWrapper);
	
	
	
	
	@Select("select * from person where pId=#{id}")
	@Results(value={
			@Result(javaType=Sex.class,column="sexId",property="sex",
					one=@One(select="com.rj.bd.sex.dao.SexMapper.selectById")),
			@Result(javaType=String.class,column="sexId",property="sexId"),
	})
	public Person selectById(String id);
	
	@Insert("insert into person (pId,pName,pPhone,sexId) values (#{pId},#{pName},#{pPhone},#{sexId})")
	public void save(Person person);
	
	@Delete("delete from person where pId=#{pId}")
	public void delete(String pId);



	@Update("update person set pName=#{pName},pPhone=#{pPhone},sexId=#{sexId} where pId=#{pId}")
	public void edit(Person person);
}
